裁剪的 ROI 端点(仅分类)
概览
The cropped_roi endpoint provides access to cropped Regions of Interest (ROIs) generated from classification results in Haystack running on the device.
重要提示: 本端点仅适用于 classification-type results(分类型结果)。 通过此端点不支持 segmentation 类型的 ROI 裁剪。
基础 URL 格式为:
http://{device-ip}/edge/haystack/cropped_roi/{classification_result_id}
工作原理
当相机完成一个 classification capture(分类捕获)时,The Node-RED 流会通过将设备 IP 与 classification result ID 配对,动态构造裁剪 ROI 图像的 URL:
const imageUrl = `http://${baseUrl}/edge/haystack/cropped_roi/${result.id}`;
每个 URL 提供一个对应于单个 classification ROI 的裁剪图像,通常表示一次单次检验。
Node-RED 流摘要
The ROI_Crop 流执行以下操作:
-
提取设备 IP
- 解析
image_url字段以查找 IP(例如192.168.0.101) - 全局存储以供重复使用
- 解析
-
查询最新捕获数据
-
向设备的 PostgREST API 发送 GET 请求:
http://{device-ip}/postgrest/captures?select=...
&order=id.desc&limit=1 -
检索最近的捕获以及所有 classification_result 条目
-
-
仅筛选 Classification 结果
-
跳过 segmentation 或 alignment 结果
-
遍历每个 classification result:
classificationResults.forEach(result => {
const roiName = result.roi_result?.inspection_region?.name || `ROI_${result.id}`;
const imageUrl = `http://${baseUrl}/edge/haystack/cropped_roi/${result.id}`;
imageMap[roiName] = imageUrl;
});
-
-
输出裁剪 ROI URL
- 将所有 ROI 图像链接保存到全局
imageMap - 返回最新裁剪 ROI 图像 URL 的列表
- 将所有 ROI 图像链接保存到全局


示例用法
获取裁剪后的 ROI 图像
curl http://192.168.0.101/edge/haystack/cropped_roi/42 -o roi_42.jpg
在 Web 界面中的使用
<img src="http://192.168.0.101/edge/haystack/cropped_roi/42" alt="Cropped ROI 42">
输出示例
{
"ROI_1": "http://192.168.0.101/edge/haystack/cropped_roi/1",
"ROI_2": "http://192.168.0.101/edge/haystack/cropped_roi/2"
}
参数
| 参数 | 类型 | 描述 |
|---|---|---|
device-ip | string | 相机 IP 地址(例如 192.168.0.101) |
集成流程
- 通过
/postgrest/captures获取最新捕获元数据。 - 标识可用的
classification_resultIDs。 - 为每个结果构造裁剪 ROI 的 URL。
- 显示或下载这些图像,以用于分析、训练数据或 QA 检查。
下载 Node-RED Flow
- ROI Crop Flow (JSON) - 提取裁剪 ROI 图像的完整 Node-RED 流
- 直接将此流导入 Node-RED 以访问 cropped classification ROIs
- 适用于 OV20i 和 OV80i 系统